package com.manage.project.biz.controller;

import java.util.List;

import com.manage.project.biz.mapper.BizGongluMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.manage.framework.aspectj.lang.annotation.Log;
import com.manage.framework.aspectj.lang.enums.BusinessType;
import com.manage.project.biz.domain.BizGonglu;
import com.manage.project.biz.service.IBizGongluService;
import com.manage.framework.web.controller.BaseController;
import com.manage.framework.web.domain.AjaxResult;
import com.manage.common.utils.poi.ExcelUtil;
import com.manage.framework.web.page.TableDataInfo;

/**
 * 公路信息Controller
 *
 * @author liutao
 * @date 2022-04-27
 */
@RestController
@RequestMapping("/biz/gonglu")
public class BizGongluController extends BaseController
{
    @Autowired
    private IBizGongluService bizGongluService;
    @Autowired
    private BizGongluMapper bizGongluMapper;

    @GetMapping("/getMaplist")
    public AjaxResult getMaplist(String sql)
    {
        return AjaxResult.success( bizGongluMapper.getMaplist(sql));
    }

    /**
     * 查询公路信息列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:gonglu:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizGonglu bizGonglu)
    {
        startPage();
        List<BizGonglu> list = bizGongluService.selectBizGongluList(bizGonglu);
        return getDataTable(list);
    }

    /**
     * 导出公路信息列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:gonglu:export')")
    @Log(title = "公路信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizGonglu bizGonglu)
    {
        List<BizGonglu> list = bizGongluService.selectBizGongluList(bizGonglu);
        ExcelUtil<BizGonglu> util = new ExcelUtil<BizGonglu>(BizGonglu.class);
        return util.exportExcel(list, "公路信息数据");
    }

    /**
     * 获取公路信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('biz:gonglu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizGongluService.selectBizGongluById(id));
    }

    /**
     * 新增公路信息
     */
//    @PreAuthorize("@ss.hasPermi('biz:gonglu:add')")
    @Log(title = "公路信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizGonglu bizGonglu)
    {

        return toAjax(bizGongluService.insertBizGonglu(bizGonglu));
    }

    /**
     * 修改公路信息
     */
    @Log(title = "公路信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizGonglu bizGonglu)
    {
        return toAjax(bizGongluService.updateBizGonglu(bizGonglu));
    }

    /**
     * 删除公路信息
     */
//    @PreAuthorize("@ss.hasPermi('biz:gonglu:remove')")
    @Log(title = "公路信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizGongluService.deleteBizGongluByIds(ids));
    }
}
